﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SpringEngine
{
    public class Velocity
    {
        private List<MotionVector> vectorComponents = new List<MotionVector>();

        public MotionVector Value
        {
            get
            {
                MotionVector vector = new MotionVector();
                foreach (MotionVector vectorComponent in vectorComponents)
                    vector += vectorComponent;
                return vector;
            }
        }

        public double X { get { return Value.X; } }
        public double Y { get { return Value.Y; } }

        public static implicit operator MotionVector(Velocity velocity)
        {
            return velocity.Value;
        }
        
        public static implicit operator Velocity(MotionVector value)
        {
            Velocity velocity = new Velocity();
            velocity.AddVector(value);
            return velocity;
        }

        public void AddVector(MotionVector vector)
        {
            vectorComponents.Add(vector);
        }

        public static Velocity operator +(Velocity x, MotionVector y)
        {
            x.AddVector(y);
            return x;
        }
    }
}
